﻿using Net5ApiANdWpfClient.Lib.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfClient
{
    /// <summary>
    /// Login.xaml 的交互逻辑
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            InitializeComponent();
        }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(UserName.Text))
            {
                MessageBox.Show("请输入用户名");
                UserName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(PassWord.Password))
            {
                MessageBox.Show("请输入密码");
                PassWord.Focus();
                return;
            }
            new AdminUserService().Login(UserName.Text, PassWord.Password);
            if (AdminUserService.LoginUser == null)
            {
                MessageBox.Show("用户名或密码错误");
                return;
            }
            MainWindow main = new MainWindow();
            main.Show();
            this.Hide();
        }

        private void LoginOut_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Application.Current.Shutdown();//在登录界面点击关闭时，关闭整个程序
        }
    }
}
